<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$con = NULL;
$debug = false;

function db_connect() {
    try {
        include("sqlinfo.php");
        global $con, $debug;
        $con = mysql_connect($db_host,$db_user,$db_pass);
        if ($debug) {
            echo '<debug>';
            echo 'Host: ' . $db_host . ', User: ' . $db_user . ', Pass: ' . $db_pass;
            echo '</debug>';
        }
    } catch (Exception $e) {
        echo '<debug>';
        echo 'sqlconnect::db_connect - Error ' .$e->getMessage();
        echo '</debug>';
    }
    
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    } else {
        mysql_select_db($db_schema, $con);
    }
}

function db_disconnect() {
    try {
        global $con;
        mysql_close($con);
    } catch (Exception $e) {
        echo '<debug>';
        echo 'sqlconnect::db_disconnect - Error ' .$e->getMessage();
        echo '</debug>';
    }
}

function db_query($query) {
    $query_result = "";
    try {
        global $con;
        $query_result = mysql_query($query,$con);
    } catch (Exception $e) {
        echo '<debug>';
        echo 'sqlconnect::db_query - Error ' .$e->getMessage();
        echo '</debug>';
    }
    return $query_result;
}
?>
